# -*- coding: utf-8 -*-
# © 2018 QYT Technology
# Authored by: Zhao Xingtao (zxt50330@gmail.com)
import arrow
import time

def format_time(utc_time, format_str='YYYY-MM-DD HH:mm:ss', timezone='Asia/Shanghai'):
    return arrow.get(utc_time).to(timezone).format(format_str)


def format_date(datetime):
    # datetime = '2018-01-01 10:40:30'
    try:
        ts = int(time.mktime(time.strptime(datetime, "%Y-%m-%d %H:%M:%S")))
    except:
        ts = int(time.mktime(time.strptime(datetime, "%Y-%m-%d")))
    return ts